﻿using PMS.Core.Caching;

namespace PMS.Plugin.ExternalAuth.DingTalkScan
{
    public class DingTalkScanAuthenticationDefaults
    {
        /// <summary>
        /// Gets a name of the view component to display login button
        /// </summary>
        public const string VIEW_COMPONENT_NAME = "DingTalkScanAuthentication";

        /// <summary>
        /// Gets a plugin system name
        /// </summary>
        public static string SystemName = "ExternalAuth.DingTalkScan";

        public static string PluginDisplayName = "钉钉";

        /// <summary>
        /// {0} - authState
        /// </summary>
        public static CacheKey LoggedinCustomerGuidCacheKey => new CacheKey("PMS.Plugin.ExternalAuth.DingTakScan.Customer.{0}");
        /// <summary>
        /// https://ding-doc.dingtalk.com/document#/org-dev-guide/obtain-access_token
        /// 源自钉钉官方文档： access_token的有效期为7200秒（2小时），有效期内重复获取会返回相同结果，过期后获取会返回新的access_token。
        /// 所有第三方登录授权获取access_token有效期都设置提前量，通过程序主动更新(如果有用到的话)
        /// </summary>
        public static int AccessTokenExpireSeconds = 7000;
        /// <summary>
        /// DingTalk WebApi GetUserIdbyUnionId
        /// POST https://oapi.dingtalk.com/topapi/user/getbyunionid?access_token=ACCESS_TOKEN
        /// Document: https://ding-doc.dingtalk.com/document#/org-dev-guide/retrieve-user-information-by-unionid-v2
        /// </summary>
        public static string DingTalkApiGetUserId = "https://oapi.dingtalk.com/topapi/user/getbyunionid";

        /// <summary>
        /// DingTalk WebApi GetUserInfoByUserId
        /// POST https://oapi.dingtalk.com/topapi/v2/user/get?access_token=ACCESS_TOKEN
        /// Document: https://ding-doc.dingtalk.com/document#/org-dev-guide/queries-user-details-v2
        /// 
        /// 调用方法简述：
        /// 1：获取access_token及unionid            https://ding-doc.dingtalk.com/document#/org-dev-guide/kymkv6
        /// 2: 根据access_token及unionid获取userid  https://ding-doc.dingtalk.com/document#/org-dev-guide/retrieve-user-information-by-unionid-v2
        /// 3: 根据access_token及userid获取userinfo https://ding-doc.dingtalk.com/document#/org-dev-guide/queries-user-details-v2
        /// </summary>
        public static string DingTalkApiGetUserInfo = "https://oapi.dingtalk.com/topapi/v2/user/get";

    }
}
